﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.ComControls.Extension;
using MINERP.DAL.Statistics;
using MINERP.COM;

namespace MINERP.Statistics.Forms.ProfessionalReports
{
    public partial class FrmFujiInnerProuctCount : Form
    {
        private static FrmFujiInnerProuctCount _instance;
        public static FrmFujiInnerProuctCount GetInstance
        {
            get
            {
                if (_instance == null || _instance.IsDisposed)
                {
                    _instance = new FrmFujiInnerProuctCount();
                }
                return _instance;
            }
        }

        private FrmFujiInnerProuctCount()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            btnOK.Enabled = false;
            Cursor = Cursors.WaitCursor;
            try
            {

                gridControl1.DataSource = FujiProductStaticDAL.GetProductInnerStatic(deStart.DateTime, deEnd.DateTime);
                gridControl1.RefreshDataSource();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.InnerException.Message);
            }
            finally
            {
                btnOK.Enabled = true;
                Cursor = Cursors.Default;
            }

        }

        private void btnExportEXCEL_Click(object sender, EventArgs e)
        {
            //导出EXCEL
            btnExport.Enabled = false;
            Cursor = Cursors.WaitCursor;
            try
            {
                //SaveFileDialog saveFileDialog = new SaveFileDialog();
                //saveFileDialog.Filter = "文本文件 (*.txt)|*.txt|pdf(*.pdf)|*.pdf|电子表格(*.xls)|*.xls|html(*.html)|*.html";

                //saveFileDialog.FilterIndex = 3;
                //saveFileDialog.RestoreDirectory = true;
                //if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                //{
                //    string fileName = saveFileDialog.FileName;
                //    if (saveFileDialog.OpenFile() != null)
                //    {
                //        switch (saveFileDialog.FilterIndex)
                //        {
                //            case 3:
                //                gridControl1.ExportToXls(fileName);
                //                return;
                //            case 4:
                //                gridControl1.ExportToHtml(fileName);
                //                return;
                //            case 2:
                //                gridControl1.ExportToPdf(fileName);
                //                return;
                //            case 1:
                //                this.gridControl1.ExportToText(fileName);
                //                return;
                //            default:
                //                break;
                //        }
                //    }

                //}

                ////DevGridViewExport.ExportToExcel("内部产品对帐表", gridView1);
               DevControlExtension.ExportToExcel(gridControl1,this,"内部对账表");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.InnerException.Message);
            }
            finally
            {
                btnExport.Enabled = true;
                Cursor = Cursors.Default;
            }
        }
    }
}
